using UnityEngine;
using System.Collections;

public class TouchHandler : MonoBehaviour {
	
	public GameObject holder;
	public RaycastHit hit = new RaycastHit();
	
	// Use this for initialization
	void Start () {}
	
	// Update is called once per frame
	void Update () {
		if( Helper.CheckTouch(gameObject) ) {
			OnMouseDown();	
		}
	}
	
//	public void CheckClick() {
//		foreach(Touch touch in Input.touches) {
//			if(touch.phase == TouchPhase.Began) {
//				// Construct a ray from the current touch coordinates
//				Ray ray = Camera.main.ScreenPointToRay(touch.position);
//				if( Physics.Raycast(ray, out hit) ) { // Check hit
//					if(hit.transform.gameObject == gameObject)
//						OnMouseDown();
//				}
//			}
//		}
//	}

    void OnMouseDown() {	
		holder.SendMessage("BeenHit", gameObject, SendMessageOptions.DontRequireReceiver);
//		gameObject.transform.Translate (0, -0.2f, 0);
//		yield return new WaitForSeconds(0.5f);
//		gameObject.transform.Translate (0, 0.2f, 0);
    }

}
